<?php

// +----------------------------------------------------------------------
// | TAODUDU.COM  [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.taodudu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: ubten <462193409@qq.com> http://www.ubten.com/
// +----------------------------------------------------------------------

namespace Admin\Controller;
use Admin\Controller\AdminController;
class ExpressController extends AdminController
{
    function _initialize() {
        parent::_initialize();
        $this->assign('sys', 'setting'); // 数据集
    }
    // 快递公司
    public function index(){
        if(I('get.e_letter')){
            $datas['e_letter'] = I('get.e_letter');
        }
        $users = M('express');
        $count = $users->where($datas)->count();// 查询满足要求的总记录数
        $Page = new \Think\Page($count,24);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show = $Page->show();// 分页显示输出
        $list = $users->where($datas)->order('e_order')->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('list',$list);// 赋值数据集
        $this->assign('pages',$show);// 赋值分页输出
        $this->assign('action', 'express');
        $this->display();
    }

    // 常用
//    public function always(){
//        $data['id'] = I('get.id');
//        $e_order = I('get.e_order');
//        $express = M('express');
//        if($e_order == 1){
//            $express->where($data)->save(array('e_order'=>2));
//            $this->success('操作成功', U('index'));
//        }else{
//            $express->where($data)->save(array('e_order'=>1));
//            $this->success('操作成功', U('index'));
//        }
//    }

    public function zhuang(){

        $v = I('v');
        $v ? $v = '0' :  $v = '1';

        $c = I('c');

        $where['id'] = I('id');

        $data[$c] = "$v";


        $re = M('express')->where($where)->save($data);

        $this->ajaxReturn($re);

    }
    
}
